package milktea.servlet.product;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import milktea.service.PRODUCTService;

/**
 * Servlet implementation class DoProductDel
 */
@WebServlet("/manage/admin_doprodel")
public class DoProductDel extends HttpServlet {


    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
//        response.setCharacterEncoding("UTF-8");
        //String id=request.getParameter("id");


        int id = Integer.parseInt(request.getParameter("id"));
        //���뵽���ݿ���û�����
        int count = PRODUCTService.del(id);
        //�ɹ���ʧ�ܵ�ȥ��
        if (count > 0) {
            response.sendRedirect("/MilkTea1/manage/admin_productselect");//һ��ʼ��ַûдȫ

        } else {
            PrintWriter out = response.getWriter();
            out.write("<script>");
            out.write("alter('用户登录失败')");
            out.write("location.href='manage/admin_productselect'");
            out.write("</script>");
        }
    }


}

	

